var t = require("../../../../@babel/runtime/helpers/typeof"), a = getApp();

Page({
    data: {
        language: "",
        activeName: "first",
        recordsList: [],
        dataInfo: {},
        love_name: "",
        play_with: [],
        isLoadMore: !0,
        page: 1,
        total_page: 0,
        current_page: 0,
        last_page: 0
    },
    onLoad: function(t) {
        this.checkrouter(), this.getData();
    },
    onChange: function(t) {
        this.setData({
            activeName: t.detail.name
        }), "first" == this.data.activeName ? this.getData() : this.getPlayWhit();
    },
    checkrouter: function() {
        try {
            var a = function() {
                for (var t = wx.getStorageSync("yz_basic_info"), a = t.popularize_page.mini.vue_route, e = 0; e < a.length; e++) if ("lovePeriod" == a[e]) return console.log(t.popularize_page.mini.mini_url + "跳转的路径"), 
                wx.showToast({
                    title: "未开启推广权限",
                    duration: 1e3,
                    icon: "none",
                    success: function() {
                        setTimeout(function() {
                            wx.redirectTo({
                                url: t.popularize_page.mini.mini_url
                            });
                        }, 1e3);
                    }
                }), {
                    v: void 0
                };
            }();
            if ("object" === t(a)) return a.v;
        } catch (t) {
            console.log(t);
        }
    },
    onReady: function() {
        var t = wx.getStorageSync("langIndex");
        this.setData({
            language: t.en
        });
    },
    onShow: function() {},
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {},
    onReachBottom: function() {
        this.data.current_page < this.data.last_page ? (wx.showLoading({
            title: "加载中",
            mask: !0
        }), this.setData({
            current_page: this.data.current_page + 1
        }), this.getMoreData()) : wx.showToast({
            title: "没有更多记录",
            icon: "none"
        });
    },
    onShareAppMessage: function() {},
    getData: function() {
        var t = this, e = a.getNetAddresss("plugin.period-return.frontend.log.index");
        e += "&page=1", a._getNetWork({
            url: e,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (t.setData({
                    dataInfo: e.data,
                    love_name: e.data.love_name,
                    isLoadMore: !0,
                    total_page: e.data.list.last_page,
                    recordsList: e.data.list.data
                }), wx.setNavigationBarTitle({
                    title: t.data.love_name + "周期奖励记录"
                })) : wx.showToast({
                    title: e.msg,
                    icon: "none"
                });
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getPlayWhit: function() {
        var t = this, e = a.getNetAddresss("plugin.period-return.frontend.log.payment-log");
        e += "&page=1", a._getNetWork({
            url: e,
            success: function(e) {
                var o = e.data.data;
                1 == e.data.result ? (t.setData({
                    play_with: o.list.data,
                    isLoadMore: !0,
                    current_page: o.list.current_page,
                    last_page: o.list.last_page
                }), wx.setNavigationBarTitle({
                    title: e.data.data.love_name + "周期奖励记录"
                })) : a.tips(e.data.msg);
            },
            fail: function(t) {
                console.log(t);
            }
        });
    },
    getMoreData: function() {
        var t = this;
        this.setData({
            isLoadMore: !1
        });
        var e = "";
        e = "first" == this.data.activeName ? "plugin.period-return.frontend.log.index" : "plugin.period-return.frontend.log.payment-log";
        var o = a.getNetAddresss(e);
        o += "&page=" + this.data.current_page, a._getNetWork({
            url: o,
            success: function(a) {
                var e = a.data;
                1 == e.result ? (wx.hideLoading(), t.setData({
                    isLoadMore: !0
                }), "first" == t.data.activeName ? t.setData({
                    recordsList: t.data.recordsList.concat(e.data.list.data)
                }) : t.setData({
                    play_with: t.data.play_with.concat(e.data.list.data)
                })) : (wx.hideLoading(), wx.showToast({
                    title: e.msg,
                    icon: "none"
                }), t.setData({
                    current_page: t.data.current_page - 1,
                    isLoadMore: !1
                }));
            },
            fail: function(t) {
                console.log(t);
            }
        });
    }
});